import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
import '@/icons' // icon
import '@/permission' // permission control
import components from '@/components'
Vue.use(components)
import * as filters from '@/filters'
for (const key in filters) {
  Vue.filter(key, filters[key])
}
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
const generateAttendanceRecord = () => {
  const res = []
  for (let index = 0; index < 31; index++) {
    res.push({
      id: '@guid',
      'adtStatu|1-6': 1,
      'day': 20211001 + index
    })
  }
  return res
}
const Arr = [{ name: '传智教育', id: 123456 }, { name: '行政部', id: 123457 }, { name: '人事部', id: 123458 }, { name: '财务部', id: 123459 }, { name: '财务核算部', id: 1234510 }, { name: '税务管理部', id: 1234520 }, { name: '薪资管理部', id: 1234521 }, { name: '技术部', id: 1234511 }, { name: 'Java研发部', id: 1234512 }, { name: 'Python研发部', id: 1234513 }, { name: 'Php研发部', id: 1234514 }, { name: '运营部', id: 1234515 }, { name: '市场部', id: 1234516 }, { name: '北京事业部', id: 1234517 }, { name: '上海事业部', id: 1234518 }, { name: '总裁办', id: 1234519 }]
import Mock from 'mockjs'
Mock.mock(/\/mockcompany/, {
  code: 10000,
  message: '哈哈哈假数据',
  success: true,
  data: {
    'depts': [...Arr]
  }
})
Mock.mock(/\/mock/, {
  code: 10000,
  message: '哈哈哈假数据',
  success: true,
  data: {
    data: {
      'rows|20': [
        { username: '@cname', 'id|13500000-13800000': 13500000, 'workNumber|1000-9999': 1000,
          'departmentName|1': ['传智教育',
            '总裁办',
            '行政部',
            '人事部',
            '财务部',
            '财务核算部',
            '税务管理部',
            '薪资管理部',
            '技术部',
            'Java研发部',
            'Python研发部',
            'Php研发部',
            '运营部',
            '市场部',
            '北京事业部',
            '上海事业部'], 'departmentId|1000000000-2000000000': 1111111111,
          'mobile|13500000000-18500000000': 13500000000, attendanceRecord: generateAttendanceRecord() }
      ],
      total: 20
    },
    monthOfReport: 3,
    tobeTaskCount: 0
  }
})
// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
Vue.use(ElementUI)
Vue.directive('imgerr', {
  inserted(el) {
    el.addEventListener('error', () => {
      el.src = 'https://img0.baidu.com/it/u=633776498,2850305968&fm=11&fmt=auto&gp=0.jpg'
    })
    el.src = el.src || 'https://img0.baidu.com/it/u=633776498,2850305968&fm=11&fmt=auto&gp=0.jpg'
  },
  componentUpdated(el) {
    el.src = el.src || 'https://img0.baidu.com/it/u=633776498,2850305968&fm=11&fmt=auto&gp=0.jpg'
  }
})
Vue.config.productionTip = false
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
